<?php
/**
 * The following code, none of which has BUG.
 *
 * @author: BD<657306123@qq.com>
 * @date: 2019/11/20 15:28
 */
declare (strict_types = 1);

namespace app\common\service;

use think\facade\App;
use think\facade\Env;

class WebPath{

	/**
	 * 获取Web公共目录
	 *
	 * @return string
	 */
	public static function getRootPath():string{
		return Env::get('web_public_path') ?: '';
	}

	/**
	 * 获取Web公共静态资源目录
	 *
	 * @return string
	 */
	public static function getStaticPath():string{
		return self::getRootPath()."/static";
	}

	/**
	 * 获取Web上传目录
	 *
	 * @return string
	 */
	public static function getUploadsPath():string{
		return self::getRootPath()."/uploads";
	}

	/**
	 * 获取Web第三方插件目录
	 *
	 * @return string
	 */
	public static function getVendorPath():string{
		return self::getStaticPath()."/vendor";
	}

	/**
	 * 获取Web模块路径
	 *
	 * @return string
	 */
	public static function getScopePath():string{
		$name = App::getInstance()->get('http')->getName();
		return self::getStaticPath()."/".$name;
	}

	/**
	 * 获取Web模块下图片路径
	 *
	 * @return string
	 */
	public static function getImagesPath():string{
		return self::getScopePath()."/images";
	}

	/**
	 * 获取Web模块下js路径
	 *
	 * @return string
	 */
	public static function getJsPath():string{
		return self::getScopePath()."/js";
	}

	/**
	 * 获取Web模块下css路径
	 *
	 * @return string
	 */
	public static function getCssPath():string{
		return self::getScopePath()."/css";
	}

	/**
	 * 获取Web模块下字体路径
	 *
	 * @return string
	 */
	public static function getFontsPath():string{
		return self::getScopePath()."/fonts";
	}
}
